//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CEffectVariable9.h>
///	@path	~/src/graphics/dx9/
///	@date	2007/11/15
///	@desc	Shader variable dx 9.

#pragma once

#include "xeres.h"

#include "graphics/IShaderVariable.h"
#include "graphics/dx9/CEffect9.h"

namespace xeres {

	/*!
		\class	CEffectVariable9
		\brief
	*/
	class CEffectVariable9 : public IShaderVariable
	{
	public:

		/// \ctor
		CEffectVariable9( RefWeak<CEffect9> effect , D3DXHANDLE param );

		/// \dtor
		virtual ~CEffectVariable9( void );

		DECL_IOBJECT_CLASS( CEffectVariable9 , IShaderVariable );

	public:

	//@ interface

		/// \name Variable Type Interface
		//@{

		/// \impl
		virtual const WString& GetVarTypeName( void ) const;

		/// \impl
		virtual const ClassID GetVarTypeID( void ) const;

		/// \impl
		virtual bool DuplicateFrom( const Ref<IVar>& val );

		/// \impl
		virtual bool SetBool( bool val );
		/// \impl
		virtual bool SetInt( int val );
		/// \impl
		virtual bool SetFloat( float val );
		/// \impl
		virtual bool SetPair( const Pair<float>& val );
		/// \impl
		virtual bool SetVector( const Vector<float>& val );
		/// \impl
		virtual bool SetQuat( const Quat<float>& val );
		/// \impl
		virtual bool SetColor( const Color4& val );
		/// \impl
		virtual bool SetMatrix( const Matrix<float>& val );
		/// \impl
		virtual bool SetString( const WString& val );

		/// \impl
		virtual bool SetObject( RefWeak<IObject> val );

		/// \impl
		virtual bool GetBool( bool& val ) const;
		/// \impl
		virtual bool GetInt( int& val ) const;
		/// \impl
		virtual bool GetFloat( float& val ) const;
		/// \impl
		virtual bool GetPair( Pair<float>& val ) const;
		/// \impl
		virtual bool GetVector( Vector<float>& val ) const;
		/// \impl
		virtual bool GetQuat( Quat<float>& val ) const;
		/// \impl
		virtual bool GetColor( Color4& val ) const;
		/// \impl
		virtual bool GetMatrix( Matrix<float>& val ) const;
		/// \impl
		virtual bool GetString( WString& val ) const;

		/// \impl
		virtual bool GetObject( Ref<IObject>& val ) const;

		//@}

		/*!
			\brief		Get master object, IEffect or IEffectPool.
		*/
		virtual RefPass< IObject > GetMaster( void );

		/*!
			\brief		Set shader variable value by IVar.
		*/
		virtual bool SetByVar( RefWeak< IVar > var );

		/*! 
			\brief		Set shader variable value by raw data.
		*/
		virtual bool SetByData( const void * data , size_t bytes );

		/*!
			\brief		Set shader variable value by ITexture.
		*/
		virtual bool SetByTexture( RefWeak< ITexture > texture );

		/*!
			\brief		Set shader variable value by IRenderTarget.
		*/
		virtual bool SetByRenderTarget( RefWeak< IRenderTarget > rt );


	private:

		//@ friend
		friend class CEffect9;

	//@ data

		// master effect
		Ref<CEffect9>		m_effect;

		// handle to parameter
		D3DXHANDLE			m_pParam;

		// description
		D3DXPARAMETER_DESC	m_desc;
	};

} // namespace xeres
